﻿using Script.Framework;
using UnityEngine.UI;

namespace Script.UI._0.Login
{
    public class PlayerPanel : UIBase
    {
        private Button btnStart;
        private Button btnRegister;

        private void Start()
        {
            btnStart = transform.Find("Btn_Start").GetComponent<Button>();
            btnRegister = transform.Find("Btn_Register").GetComponent<Button>();

            btnStart.onClick.AddListener(startClick);
            btnRegister.onClick.AddListener(registerClick);
        }

        private void startClick()
        {
            Dispatch(AreaCode.UI, UIEvent.START_PANEL_ACTIVE, true);
        }

        private void registerClick()
        {
            Dispatch(AreaCode.UI, UIEvent.REGISTER_REALIST_PANEL_ACTIVE, true);
        }

        public override void OnDestroy()
        {
            base.OnDestroy();

            btnRegister.onClick.RemoveAllListeners();
            btnStart.onClick.RemoveAllListeners();
        }
    }
}